<?php

/*
	Class: DealersDealersCountries

	About: Author
		Rich Joslin

	About: License
		<http://communit.as/docs/license>

	About: See Also
		- <Cts_Db_Table_Abstract>
*/
class DealersDealersCountries extends Cts_Db_Table_Abstract {

	/* Group: Instance Variables */

	/*
		Variable: $_name
	*/
	protected $_name = 'dealers_dealers_countries';

	/*
		Variable: $_primary
	*/
	protected $_primary = array('dealer_id', 'country_code');

	/* Group: Instance Methods */

	/*
		Function: deleteByDealerId
	*/
	function deleteByDealerId($dealer_id) {
		$where = $this->getAdapter()->quoteInto('dealer_id = ?', $dealer_id);
		$this->delete($where);
	}

	/*
		Function: insertMulti

		Arguments:
			dealer_id - The ID of the dealer to associate.
			country_ids - An array of category IDs to associate.

		Returns: void
	*/
	function insertMulti($dealer_id, array $country_ids) {
		foreach ($country_ids as $country_code) {
			$this->insert(array(
				'dealer_id' => $dealer_id,
				'country_code' => $country_code,
				'created_on' => date(DB_DATETIME_FORMAT),
				'last_modified_on' => date(DB_DATETIME_FORMAT),
			));
		}
	}

}
